module tb_prbs_test;

    reg clk = 0, rst = 1, enable = 0;
    wire prbs_bit;
    wire done;
    wire detected;

    prbs_generator gen (
        .clk(clk),
        .rst(rst),
        .enable(enable),
        .prbs_bit(prbs_bit)
    );

    prbs_checker chk (
        .clk(clk),
        .rst(rst),
        .enable(enable),
        .prbs_bit(prbs_bit),
        .done(done),
        .detected(detected)
    );

    always #5 clk = ~clk;  // 100MHz

    initial begin
        $dumpfile("prbs_test.vcd");
        $dumpvars(0, tb_prbs_test);

        #20 rst = 0;
        enable = 1;

        wait (done);
        #10;
        if (detected)
            $display("PRBS detected correctly!");
        else
            $display("PRBS detection failed!");

        $stop;
    end

endmodule
